angular.module('module.home', [
    'ngCookies'
])
    .config(['$stateProvider',   '$urlRouterProvider',
        function($stateProvider, $urlRouterProvider) {
            $stateProvider
                .state('home', {
                    url : '/home',
                    templateUrl : 'view/home/home.html',
                    controller : 'HomeController'
                })
        }])
    .controller('HomeController', ['$scope','$state','HomeService','$cookieStore','OrderService',
        function($scope,$state,HomeService,$cookieStore,OrderService) {
            $scope.submit = function (code) {
                $('#send_set').attr("disabled","true");
                if ($scope.code) {
                    HomeService.updateByid($scope.code, function (data) {
                        console.log(data)
                        OrderService.getOrder();
                        $('#send_set').attr("disabled","true");
                    }, function (data) {
                        swal(data.data.reason, "请输入正确的核销码", "error");
                        $('#send_set').removeAttr("disabled");
                    });
                }
                else {
                    swal("发现一个错误", "请输入核销码！", "error");
                    $('#send_set').removeAttr("disabled");
                }

            };
            /*密码输入框*/
            password(".fake-box1 input", "#pwd-input", "send_set");
        }])
    .controller('SuccessController', ['$scope','$state','HomeService','$cookieStore',
        function($scope,$state,HomeService,$cookieStore) {

        }])